﻿using DataStructure;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace DataStructure.Test
{


    /// <summary>
    ///This is a test class for BinaryTreeTest and is intended
    ///to contain all BinaryTreeTest Unit Tests
    ///</summary>
    [TestClass()]
    public class BinaryTreeTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for BinaryTree Constructor
        ///</summary>
        [TestMethod()]
        public void BinaryTreeConstructorTest()
        {
            BinaryTree target = new BinaryTree();
            Assert.Inconclusive("TODO: Implement code to verify target");
        }

        /// <summary>
        ///A test for InOrderTraverse
        ///</summary>
        public void InOrderTraverseTestHelper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.InOrderTraverse<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void InOrderTraverseTest()
        {
            BinaryTreeNode<int> root = new BinaryTreeNode<int>()
                {
                    data = 0,
                    Left = new BinaryTreeNode<int>()
                    {
                        data = 1,
                        Left = new BinaryTreeNode<int>()
                        {
                            data = 12,
                            Left = new BinaryTreeNode<int>() { data = 2 },
                            Right = new BinaryTreeNode<int>()
                            {
                                data = 3,
                                Left = new BinaryTreeNode<int>() { data = 4 },
                                Right = new BinaryTreeNode<int>() { data = 5 }
                            }
                        },
                        Right = new BinaryTreeNode<int>()
                        {
                            data = 6,

                            Left = new BinaryTreeNode<int>() { data = 7 },
                            Right = new BinaryTreeNode<int>() { data = 8 }
                        }
                    },
                    Right = new BinaryTreeNode<int>()
                    {
                        data = 9,
                        Right = new BinaryTreeNode<int>()
                        {
                            data = 10,

                            Left = new BinaryTreeNode<int>() { data = 11 },
                            Right = new BinaryTreeNode<int>() { data = 12 }
                        }
                    }
                };


            BinaryTree.InOrderTraverseInStack<int>(root, (i) => { Console.WriteLine(i.data); });

        }

        /// <summary>
        ///A test for InOrderTraverseInStack
        ///</summary>
        public void InOrderTraverseInStackTestHelper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.InOrderTraverseInStack<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void InOrderTraverseInStackTest()
        {
            InOrderTraverseInStackTestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for InOrderTraverseInStack2
        ///</summary>
        public void InOrderTraverseInStack2TestHelper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.InOrderTraverseInStack2<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void InOrderTraverseInStack2Test()
        {
            InOrderTraverseInStack2TestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for LevelTraverse
        ///</summary>
        [TestMethod()]
        public void LevelTraverseTest()
        {
            BinaryTree tree = null; // TODO: Initialize to an appropriate value
            BinaryTree.LevelTraverse(tree);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for PostOrderTraverse
        ///</summary>
        public void PostOrderTraverseTestHelper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.PostOrderTraverse<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void PostOrderTraverseTest()
        {
            PostOrderTraverseTestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for PreOrderTraverse
        ///</summary>
        public void PreOrderTraverseTestHelper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.PreOrderTraverse<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void PreOrderTraverseTest()
        {
            PreOrderTraverseTestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for InOrderTraverse
        ///</summary>
        public void InOrderTraverseTest1Helper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.InOrderTraverse<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void InOrderTraverseTest1()
        {
            InOrderTraverseTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for BinaryTree Constructor
        ///</summary>
        [TestMethod()]
        public void BinaryTreeConstructorTest1()
        {
            BinaryTree target = new BinaryTree();
            Assert.Inconclusive("TODO: Implement code to verify target");
        }

        /// <summary>
        ///A test for InOrderTraverseInStack
        ///</summary>
        public void InOrderTraverseInStackTest1Helper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.InOrderTraverseInStack<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void InOrderTraverseInStackTest1()
        {
            InOrderTraverseInStackTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for InOrderTraverseInStack2
        ///</summary>
        public void InOrderTraverseInStack2Test1Helper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.InOrderTraverseInStack2<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void InOrderTraverseInStack2Test1()
        {
            InOrderTraverseInStack2Test1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for LevelTraverse
        ///</summary>
        [TestMethod()]
        public void LevelTraverseTest1()
        {
            BinaryTree tree = null; // TODO: Initialize to an appropriate value
            BinaryTree.LevelTraverse(tree);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for PostOrderTraverse
        ///</summary>
        public void PostOrderTraverseTest1Helper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.PostOrderTraverse<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void PostOrderTraverseTest1()
        {
            PostOrderTraverseTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for PreOrderTraverse
        ///</summary>
        public void PreOrderTraverseTest1Helper<T>()
        {
            BinaryTreeNode<T> root = null; // TODO: Initialize to an appropriate value
            HandleNode<T> handler = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = BinaryTree.PreOrderTraverse<T>(root, handler);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void PreOrderTraverseTest1()
        {
            PreOrderTraverseTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for GenerateBinaryTreeWithMininalHeight
        ///</summary>
        [TestMethod()]
        public void GenerateBinaryTreeWithMininalHeightTest()
        {
            int[] sorted = {1,2,3,4,5,6,7,8,9,10}; // TODO: Initialize to an appropriate value
            int start = 0; // TODO: Initialize to an appropriate value
            int end = sorted.Length-1; // TODO: Initialize to an appropriate value
            
            BinaryTreeNode<int> actual;
            actual = BinaryTree.GenerateBinaryTreeWithMininalHeight(sorted, start, end);
            Assert.AreEqual<int>(5, actual.data);
        }

        [TestMethod()]
        public void GenerateBinaryTreeWithMininalHeight2Test()
        {
            int[] sorted = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // TODO: Initialize to an appropriate value

            BinaryTreeNode<int> actual;
            actual = BinaryTree.GenerateBinaryTreeWithMininalHeight(sorted);
            Assert.AreEqual<int>(5, actual.data);
        }
    }
}
